<?php

class MemberOrganizationalPropertyType extends AbstractOrganizationalPropertyType
{

  public function getDisplayValue ($value)
  {
    $member = MemberTable::getInstance()->findOneById($value);
    if ($member instanceof Member)
    {
      return sprintf('%s %s', $member->getFirstName(), $member->getLastName());
    }
    else
    {
      throw new OrganizationalPropertyInconsistencyException();
    }
  }

  function getFormWidget ($options = array())
  {
    $options = array_merge($options, array('unit' => $this->unit, 'add_empty' => true));
    $widget = new WidgetFormOrganizationalUnitMemberChoice($options);
    return $widget;
  }

  function getFormWidgetValidator ($options = array())
  {
    return new sfValidatorString();
  }
}